package com.zzccyy.jpdemo.utils;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.zzccyy.jpdemo.R;


public class CenterLoadingDialog extends Dialog {


    private Activity activity;



    /**
     * @param activity
     */
    public CenterLoadingDialog(Activity activity) {
        super(activity, R.style.pop_loading_pop);
        this.activity = activity;

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.center_loading);
        setCancelable(true);


    }


    @Override
    public void show() {
        Window window = getWindow();
        window.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;//如果不设置,可能部分机型出现左右有空隙,也就是产生margin的感觉
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;


        window.setAttributes(params);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        getWindow().setAttributes(lp);
        super.show();
    }

}
